#!/bin/bash
# 关闭给定名称的进程
# 校验参数
if [ $# -lt 1 ]
then
  echo "please give process name"
  exit 1
fi
echo "kill process $1"
# 获取相关进程的pid
pids=`ps -ef | grep $1 -w | grep 'grep|kill-process-by-name' -vE | awk '{print $2}'`
echo $pids
# 执行关闭进程操作
for pid in $pids
do
  echo "Kill the $1 process [ $pid ]"
  kill -9 $pid
done
